package com.example.interesting.distributed.lock.test.controller;

import com.example.interesting.distributed.lock.test.dto.UserDTO;
import com.example.interesting.distributed.lock.test.service.LockService;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fyw
 * @version 1.0
 * @description: 测试分布式锁
 * @date 2024/3/17 14:44
 */
@RestController
@RequestMapping("/lock")
@RequiredArgsConstructor
public class LockController {

    private final LockService lockService;


    /**
     * 编程式锁
     */
    @GetMapping("/programmaticLocking")
    public Object programmaticLocking() {
        lockService.programmaticLocking();
        return null;
    }

    /**
     * 注解式锁
     */
    @GetMapping("/annotationLocking")
    public void annotationLocking() {
        UserDTO userDTO = new UserDTO();
        lockService.annotationLocking(userDTO);
    }
}
